<html style="min-width:inherit;">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<link href="/static/public/layer/src/css/layui.css" rel="stylesheet">
<script src="/static/public/jquery-1.11.1.min.js" type="text/javascript"></script>
<script src="/static/public/layer/src/layui.js"></script>
</head>
<body>
<style>
html,body{ min-width:400px; overflow:visible; background:#FFF;}
.tiwen_box{ width:400px; padding:0 50px;}
.wtwolist ul{ margin-right:-24px;}
.wtwolist li .wtwls{ padding:10px 24px 0 0; width:120px;}
.it_wire_wt{ clear:both; overflow:hidden; padding:0 25px; border:1px solid #e4e4e4; height:50px; line-height:50px;}
.it_wire_wt input{ border:none; background:none; height:100%; width:100%;}
.bor-1aa3fa .wtwls a.curr{background-color: #1aa3fa;color: #FFF;}
</style>
<div class="tiwen_box fix fs14" style="margin-top: 40px;">

<form class="layui-form layui-form-pane" method="post" id="form_add_role">
	<input type="hidden" value="<{$sx_id}>" name="sx_id">
	<div class="layui-form-item">
		<label style="width:105px" class="layui-form-label">售价</label>
		<div class="layui-input-inline">
			<input type="text" value="<{if isset($pack_info)}><{$pack_info.price}><{/if}>" name="price" placeholder="请输入价格" lay-verify="required" autocomplete="off" class="layui-input" style="width: 170px;"> 
		</div>
		<{if isset($school_order_info) AND $school_order_info > 0}>
		<div class="layui-form-mid layui-word-aux">总部售价：<{$school_order_info.price}></div>
		<{/if}>
	</div>
	<div class="layui-form-item">
		<label style="width:105px" class="layui-form-label">佣金百分比</label>
		<div class="layui-input-inline">
			<input type="text" value="<{if isset($pack_info)}><{$pack_info.commission}><{/if}>" name="commission" placeholder="请填写佣金百分比" lay-verify="required" onkeyup="this.value=this.value.replace(/[^0-9]/g,'')" onafterpaste="this.value=this.value.replace(/[^0-9]/g,'')" maxlength="2" autocomplete="off" class="layui-input" style="width: 300px;">
		</div>
	</div>
	<div class="layui-form-item">
		<label style="width:105px" class="layui-form-label">有效天数</label>
		<div class="layui-input-inline">
			<input type="text" <{if isset($code_info) AND $code_info.expire_day > 0}> value="<{$code_info.expire_day}>"<{else}>value="<{if isset($pack_info) AND $pack_info.expire_day > 0}><{$pack_info.expire_day}><{else}>180<{/if}>"<{/if}> max_day="<{$school_order_info.expire_day|default:180}>" id="expire_day" name="expire_day" placeholder="自用户购买日期起之后的多少天内有效" lay-verify="required|number"  autocomplete="off" class="layui-input" style="width: 300px;">
		</div>
	</div>
	<div class="layui-input-block">
		<a class="layui-btn" id="submit" lay-submit lay-filter="*">立即提交</a>
		<button type="reset" class="layui-btn layui-btn-primary">重置</button>
	</div>
</form>
</div>
<script>

window.onload= function(){
	var linkList=window.parent.document.getElementsByTagName("link");//获取父窗口link标签对象列表
	var head=document.getElementsByTagName("head").item(0);
	//外联样式
	for(var i=0;i<linkList.length;i++){
	var l=document.createElement("link");
		l.rel = 'stylesheet'
		l.type = 'text/css'; 
		l.href=linkList[i].href;
		head.appendChild(l);
	}
}

$("#expire_day").change(function(){
	var day = $(this).val();
	var max_day = $(this).attr("max_day");
	if(parseInt(day) > parseInt(max_day)){
		$(this).val(max_day);
	}
})

$("#submit").click(function(){
	$.ajax({
		type: "POST",
		url: "/shixun/shelves",
		dataType:"json",
		async:false,
		data:$("#form_add_role").serializeArray(),
		contentType:'application/x-www-form-urlencoded',
		success: function(result){
			if(result.code == 1){
				var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
        		parent.layer.close(index);
        		parent.layer.msg('上架成功', {
			        icon: 1,
			        shade:0.5,
			        time: 2000 //2秒关闭（如果不配置，默认是3秒）
			    });
			}else if(result.code == 2){
				var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
        		parent.layer.close(index);
        		parent.layer.msg('修改成功', {
			        icon: 1,
			        shade:0.5,
			        time: 2000 //2秒关闭（如果不配置，默认是3秒）
			    });
			}else{
				var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
        		parent.layer.close(index);
        		parent.layer.msg('无法重复上架', {
			        icon: 2,
			        shade:0.5,
			        time: 2000 //2秒关闭（如果不配置，默认是3秒）
			    });
			}
		}
	});
})
</script>
</body>
</html>
